﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Icedream.InstantFileTransfer
{
    public class IFTPFileHeader
    {
        internal string _headerName = null;
        internal string _headerValue = null;

        public string Name { get { return _headerName; } }
        public string Value { get { return _headerValue; } }
        public bool IsEnd { get { return _headerName == null && _headerValue == null; } }

        internal static IFTPFileHeader ParseLine(string line)
        {
            IFTPFileHeader h = new IFTPFileHeader();
            if (line.ToUpper().StartsWith("EOINFO"))
                return h;

            h._headerName = line.Split(':')[0].ToLower();
            h._headerValue = line.Substring(h._headerName.Length + 1).Trim('"', ' ', '\t', '\r');

            return h;
        }
    }
}
